package miiteen.customsportal.Api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.customsportal.basic.beans.BasicNavigation;
import miiteen.customsportal.basic.service.BasicNavigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 导航栏
 *
 */
@Api(tags = "导航栏")
@RestController
@RequestMapping("/Api/basicNavigation")
@CrossOrigin
public class BasicNavigationApiController {



    @Autowired
    private BasicNavigationService basicNavigationService;

    @ApiOperation("列表页面")
    @GetMapping("findByList")
    public ResultMessage GetList(){

        Map<String,Object> map=new HashMap<>();
        map.put("parentId",9);
        List<BasicNavigation> parentList=basicNavigationService.findListByMap(map);
        if(parentList!=null && parentList.size()>0){
            map.put("parentId",-1);
            for(BasicNavigation basicNavigation:parentList){
                map.put("parentIds",basicNavigation.getId());
                List<BasicNavigation> list=basicNavigationService.findListByMap(map);
                basicNavigation.setTwoList(list);
            }
            return ResultMessageTool.Success("success",parentList);
        }
        return ResultMessageTool.Error("未找到相关信息！");
    }


}
